package com.yunxi.service.localService.impl.sto;

import com.github.pagehelper.PageInfo;
import com.yunxi.core.page.PageHelperPlus;
import com.yunxi.dao.sto.PartnerVehicleTradeMapper;
import com.yunxi.model.sto.PartnerVehicleTrade;
import com.yunxi.service.localService.sto.PartnerVehicleTradeService;
import com.yunxi.sto.pojo.PartnerVehicleTradeApproveHisVO;
import com.yunxi.sto.pojo.PartnerVehicleTradeDetailListVO;
import com.yunxi.sto.pojo.PartnerVehicleTradeVO;
import org.springframework.stereotype.Service;
import com.yunxi.core.service.ServiceImplPlus;
import java.util.List;

/**
 * <p>
 * 渠道商车辆买卖 服务实现类
 * </p>
 *
 * @author caoYong
 * @since 2019-08-30
 */
@Service
public class PartnerVehicleTradeServiceImpl extends ServiceImplPlus<PartnerVehicleTradeMapper, PartnerVehicleTrade> implements PartnerVehicleTradeService {

    /**
     * 买卖车辆详情列表
     * @param tradeId
     * @return
     * @throws Exception
     */
    @Override
    public List<PartnerVehicleTradeDetailListVO> detailList(String tradeId) throws Exception {
        return baseMapper.detailList(tradeId);
    }

    /**
     * 审核列表
     * @param partnerVehicleTradeVO
     * @param pageNum
     * @param pageSize
     * @return
     * @throws Exception
     */
    @Override
    public PageInfo<PartnerVehicleTradeVO> saleFromManager(PartnerVehicleTradeVO partnerVehicleTradeVO, Integer pageNum, Integer pageSize) throws Exception {
        PageHelperPlus.startPage(pageNum,pageSize);
        List<PartnerVehicleTradeVO> list = baseMapper.saleFromManager(partnerVehicleTradeVO);
        PageInfo<PartnerVehicleTradeVO> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    /**
     * 审核历史分页
     * @param partnerVehicleTradeVO
     * @param pageNum
     * @param pageSize
     * @return
     * @throws Exception
     */
    @Override
    public PageInfo<PartnerVehicleTradeApproveHisVO> approveHis(PartnerVehicleTradeVO partnerVehicleTradeVO, Integer pageNum, Integer pageSize) throws Exception {
        PageHelperPlus.startPage(pageNum,pageSize);
        List<PartnerVehicleTradeApproveHisVO> list = baseMapper.approveHis(partnerVehicleTradeVO);
        PageInfo<PartnerVehicleTradeApproveHisVO> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    /**
     * 获取详情
     * @param id
     * @return
     * @throws Exception
     */
    @Override
    public PartnerVehicleTradeVO getDetailById(String id) throws Exception {
        return baseMapper.getDetailById(id);
    }

    /**
     * 根据渠道商代码查询大区代码
     * @param partnerCode
     * @return
     * @throws Exception
     */
    @Override
    public String queryAreaCodeByPartnerCode(String partnerCode) throws Exception {
        return baseMapper.queryAreaCodeByPartnerCode(partnerCode);
    }

    /**
     * 根据用户代码查询大区代码
     * @param userCode
     * @return
     * @throws Exception
     */
    @Override
    public String queryAreaCodeByUserCode(String userCode) throws Exception {
        return baseMapper.queryAreaCodeByUserCode(userCode);
    }
}
